package com.acegear.horizon.domain.models;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Service;

import redis.clients.jedis.Jedis;

/**
 * Created by wangsike on 2016/12/10.
 */
@Service
@Configuration
public class ModelFactory {
    @Autowired
    private Jedis jedis;

    @Value("${horizon.domain.user.idKey}")
    private String userIdKey;

    @Value("${horizon.domain.post.idKey}")
    private String postIdKey;

    @Value("${horizon.domain.qa.idKey}")
    private String qaIdKey;

    @Value("${horizon.domain.comment.idKey}")
    private String commentIdKey;

    public Long nextUserId() {
        return jedis.incr(userIdKey);
    }

    public Long nextPostId() {
        return jedis.incr(postIdKey);
    }

    public Long nextQAId() {
        return jedis.incr(qaIdKey);
    }

    public Long nextCommentId() {
        return jedis.incr(commentIdKey);
    }
}
